Open up a Terminal and do the following steps:
mkdir Notebooks
)conda init bash
and if it asks any yes or no questions, just hit returnconda activate
to set up your environment to run our data science frameworksjupyter notebook
to start up the serverThis last starts up a Jupyter server and will automatically start your web browser if it wasn't already running. The server is what executes the things you run in the notegbook.
The Jupyter Home Page is ready for you start creating. You should see something like this, but without all the files:
Click the New
button near the upper right hand corner to begin a new Notebook page. It's a pull-down menu; generally we'll want a Python3 page but notice that you can create a text file, a new directory, or even open an online Terminal (try it and see...later).
Your new page looks something like:
A few cosmetic things to get started:
Code
select Markdown
In [ ]:
) type ## My First Notebook
, then type Shift-Enter
(shift key and enter key together)Now your page will look like this
For more about the formatting you can do in Markdown cells, see this bit or this other bit
Now to make sure of the setup, run some Python. Copy the script below into a code cell and execute by simply typing Shift-Enter
:
import matplotlib.pyplot as plt
princ = 10000
int_rate = 0.05
years = 20
values = []
for _ in range(years+1):
values.append(princ)
princ += princ*int_rate
plt.plot(values)
plt.title('5% Growth')
plt.xlabel('Years of Compounding')
plt.ylabel('Value of Principlal ($)')
If you get a proper graph from that, terrific. Now to complete the task, save the Notebook page, then go to the File
menu, select Download As
and pick HTML
. You can save this HTML version of the file in the same directory the notebook is in. Now in the browser you can do File -> Open File... and load the HTML version of your notebook into the browser as a static web page. Demonstrate this page to the instructor.
We'll talk about how HTML files go on our webserver later.
To finish up, click the Logout
button in the upper right hand corner. You can now close the tab. Go back to the tab labeled Home Page and click the Quit
button. Then just to be sure, change back to the Terminal window where you started the Jupyter notebook server to begin with; typing Ctrl-C
twice should shut down the server.
Finally, to leave the Data Science virtual environment, issue the command conda deactivate
.